<template>
    <el-dialog :visible.sync="visible" :close-on-press-escape="false" :close-on-click-modal="false" width="500px">
        <el-form v-model="importForm" label-position="left" label-width="80px">
            <el-form-item label="导入类目">
                <dic-catalog-tree v-model="importForm.catId" dic-code="course_file_catalog" />
            </el-form-item>

            <el-form-item label="导入方式">
                <el-radio v-model="importForm.type" :label="1">下级目录及课件</el-radio>
                <el-radio v-model="importForm.type" :label="2">本目录及其课件</el-radio>
            </el-form-item>
        </el-form>

        <div slot="footer">
            <el-button type="primary" @click="handleImport">确认导入</el-button>
        </div>
    </el-dialog>
</template>

<script>
import DicCatalogTree from "@/components/DicTreeSelect";

export default {
    name: "ImportDialog",
    components: {
        DicCatalogTree
    },
    props: {
        visible: {
            type: Boolean,
            default: false
        },
        excludes: {
            type: Array,
            default: () => []
        }
    },
    data() {
        return {
            importForm: {
                catId: null,
                type: 1,
                excludes: []
            }
        };
    },
    watch: {
        excludes: {
            handler(val) {
                this.importForm.excludes = val;
            },
            immediate: true
        }
    },
    methods: {
        handleImport() {
            this.$emit('import', this.importForm);
            this.$emit('update:visible', false);
        }
    }
};
</script>
